package drds.global_transaction.transaction_coordinator.store;

public enum OperationType
{
	add_global_transaction((byte) 1), update_global_transaction((byte) 2), remove_global_transaction((byte) 3),
	//
	add_branch_transaction((byte) 4), update_branch_transaction((byte) 5), remove_branch_transaction((byte) 6);

	private byte code;

	OperationType(byte code)
	{
		this.code = code;
	}

	//
	public static OperationType getLogOperationByCode(byte code)
	{
		OperationType operationType = null;
		switch (code)
		{
		case 1:
			operationType = OperationType.add_global_transaction;
			break;
		case 2:
			operationType = OperationType.update_global_transaction;
			break;
		case 3:
			operationType = OperationType.remove_global_transaction;
			break;
		case 4:
			operationType = OperationType.add_branch_transaction;
			break;
		case 5:
			operationType = OperationType.update_branch_transaction;
			break;
		case 6:
			operationType = OperationType.remove_branch_transaction;
			break;
		default:
		}
		return operationType;
	}

	public byte getCode()
	{
		return this.code;
	}

}
